<div ng-init="vm.init()">
  <h3 class="page-header">财物分类</h3>
  <div class="panel panel-default" ng-init="isOpen = true">
    <div class="panel-heading">
      <i class="glyphicon glyphicon-search"></i> 搜索条件
      <div class="btn-group pull-right">
        <button type="button" class="btn btn-default btn-xs" ng-click="isOpen = !isOpen">
          <i class="glyphicon" ng-class="{'glyphicon-chevron-down': isOpen, 'glyphicon-chevron-right':!isOpen}"></i>
        </button>
      </div>
    </div>
    <div class="panel-collapse collapse" ng-class="{'in': isOpen, '': !isOpen}">
      <div class="panel-body">
        <form class="form-inline">
          <div class="form-group">
            <label class="control-label">分类名称</label>
            <input class="form-control" ng-model="vm.categoryName">
          </div>
          <button type="button" class="btn btn-primary" ng-click="vm.search(true)">
              <i class="glyphicon glyphicon-search"></i> 搜 索</button>
          <button type="reset" class="btn btn-warning" ng-click="vm.reset()">
              <i class="glyphicon glyphicon-repeat"></i> 重置</button>
        </form>
      </div>
    </div>
  </div>
  <div class="panel panel-default">
    <div class="panel-heading">
      <i class="glyphicon glyphicon-th-list"></i> 搜索结果
      <div class="pull-right">
        <div class="btn-group">
          <button type="button" class="btn btn-default btn-xs dropdown-toggle" data-toggle="dropdown">操作
              <span class="caret"></span></button>
          <ul class="dropdown-menu pull-right">
            <li><a href="javascript:void(0)" ng-click="vm.editParent()">添加</a></li>
            <li><a href="javascript:void(0)" ng-click="vm.removeAll()">删除</a></li>
          </ul>
        </div>
      </div>
    </div>
    <div class="panel-body" style="overflow: auto">
      <div style="min-width: 992px; margin: 0 -15px">
        <div style="padding: 0 15px">
          <table class="table table-bordered table-striped" ng-table="vm.tableParams" show-group="false">
            <colgroup>
              <col width="5%">
              <col width="30%">
              <col width="30%">
              <col width="20%">
              <col width="15%">
            </colgroup>
            <tr class="ng-table-group" ng-repeat-start="group in $groups">
              <td selector="'group'" data="group"></td>
              <td colspan="3">
                <a href="javascript:void(0)" ng-click="group.$hideRows = !group.$hideRows">
                  <span class="glyphicon"
                      ng-class="{'glyphicon-chevron-right': group.$hideRows, 'glyphicon-chevron-down': !group.$hideRows}"></span>
                  <strong>{{group.data[0].parentName}}</strong>
                </a>
              </td>
              <td class="text-center">
                <button type="button" class="btn btn-primary btn-xs" uib-tooltip="修改" ng-click="vm.editParent(group.data[0])">
                    <i class="glyphicon glyphicon-pencil"></i></button>
                <button type="button" class="btn btn-danger btn-xs" uib-tooltip="删除" ng-click="vm.removeParent(group.data[0])">
                    <i class="glyphicon glyphicon-trash"></i></button>
              </td>
            </tr>
            <tr ng-hide="group.$hideRows" ng-repeat="category in group.data" ng-if="category.parentId != category.id" ng-repeat-end>
              <td selector="'item'" group="group.value" key="['id']" data="category"></td>
              <td data-title="'分类名称'" sortable="'name'">{{category.name}}</td>
              <td data-title="'更新时间'" sortable="'update_time'" class="text-center">{{category.updateTime | date:'yyyy-MM-dd HH:mm:ss'}}</td>
              <td data-title="'更新人'">{{category.updateBy}}</td>
              <td data-title="'操作'" class="text-center">
                <button type="button" class="btn btn-primary btn-xs" uib-tooltip="修改" ng-click="vm.editSub(category, true)">
                    <i class="glyphicon glyphicon-pencil"></i></button>
                <button type="button" class="btn btn-danger btn-xs" uib-tooltip="删除" ng-click="vm.removeSub(category)">
                    <i class="glyphicon glyphicon-trash"></i></button>
              </td>
            </tr>
            <tr class="warning" ng-show="$groups.length == 0">
              <td colspan="5" class="text-center">没有数据</td>
            </tr>
          </table>
        </div>
      </div>
    </div>
  </div>
</div>
